#ifndef STUDENTLIST_H
#define STUDENTLIST_H
/************************************************************
** Tim Huerter
** Mark Bordignon
** CS 235
** Final Project
** File name: studentList.h
** Description:   This header contains the function prototypes
**                for initializing and maintaining the students
**                and grades linked lists.
**
************************************************************/
#include <stdbool.h>
#include <sys/types.h>

#define MAXNAME 80

struct gradeStruct {
   char name[MAXNAME];
   float grade;
   int ident;
   int classification;
   int count;
   struct gradeStruct* prev;
   struct gradeStruct* next;
};
typedef struct gradeStruct gradeType;

struct student {
   char firstname[MAXNAME];
   char lastname[MAXNAME];
   int ident;
   gradeType* studentGrades;
   struct student* prev;
   struct student* next;
};
typedef struct student studentType;

struct gradeBook {
   char name[MAXNAME];
   int ident; // this may not be needed
   studentType* master;
};
typedef struct gradeBook gradebookType;
char fileName[80];

/********************** Student Methods ***********************/

studentType nullStudent();

/************************************************************
** function:     initStudentList
** description:  Initialize the students linked list
** notes:
************************************************************/
studentType* initStudentList(studentType master);

void initUpdateHead(gradeType* gradeList);

studentType* getMaster();

/************************************************************
** function:     deallocateStudents
** description:  free up memory allocated for student list
**               objects.
** notes:        should be called when gracefully exiting
**               the program.
************************************************************/
void deallocateStudents();

/************************************************************
** function:      addStudent
** description:   inserts a new student into the list.
** notes:         grades are sorted by last name.
************************************************************/
void addStudent(studentType student);

/************************************************************
** function:      delStudent
** description:   deletes a student from the list.
** notes:         if student id is not found, nothing happens.
************************************************************/
void delStudent(int id);

/************************************************************
** function:      printStudent
** description:   prints the student id, and name.
** notes:         none.
************************************************************/
void printStudent(studentType *std);

/************************************************************
** function:      printStudents
** description:   prints all the students in the class.
** notes:         none.
************************************************************/
int printStudents(studentType *head);

/************************************************************
** function:      editStudent
** description:   edits the student specified by id.
** notes:         none.
************************************************************/
studentType* editStudent(int id);

/************************************************************
** function:      getActiveStudent
** description:   returns the active student object.
** notes:         none.
************************************************************/
studentType* getActiveStudent();

/************************************************************
** function:      setActiveStudent
** description:   updates the active student object.
** notes:         none.
************************************************************/
void setActiveStudent(studentType* std);

/************************************************************
** function:      getStudent
** description:   returns the student object for the passed id.
** notes:         returns NULL the id is not found.
************************************************************/
studentType* getStudent(int id);

/************************************************************
** function:      getFirstStudent
** description:   returns the head of the student list.
** notes:         none.
************************************************************/
studentType* getFirstStudent();

/************************************************************
** function:      getNextStudent
** description:   returns the next student in the list.
** notes:         returns NULL if 's' is the last student in
**                the list.
************************************************************/
studentType* getNextStudent(studentType* s);

/************************************************************
** function:
** description:   returns the previous student in the list.
** notes:         returns NULL if 's' is the first student in
**                the list.
************************************************************/
studentType* getPrevStudent(studentType* s);

/************************************************************
** function:      checkStdID
** description:   returns true if the selection value is 
**	notes:			found in the student linked list given.
** 		         none.
************************************************************/
bool checkStdID(studentType* std, int selection);


/********************** Grade Methods ***********************/

/************************************************************
** function:      initGradeList
** description:   Initialize the grades linked list
** notes:         none.
************************************************************/
gradeType* initGradeList();

/************************************************************
** function:      deallocateGrades
** description:   free up memory allocated for grade list
**                objects.
** notes:         should be called when gracefully exiting
**                the program.
************************************************************/
void deallocateGrades(gradeType* gList);

/************************************************************
** function:      addGrade
** description:   inserts a new grade into the list.
** notes:         grades are sorted by id.
************************************************************/
void addGrade(gradeType grade, gradeType* stdGrades);

/************************************************************
** function:      delGrade
** description:   deletes a grade from the list.
** notes:         if grade id is not found, nothing happens.
************************************************************/
void delGrade(int id, gradeType* gList);

/************************************************************
** function:      editGrade
** description:   edits the grade specified by id.
** notes:         none.
************************************************************/
gradeType* editGrade(int id, gradeType* gList);

/************************************************************
** function:      printGrades
** description:   prints all the grades from 'g' to the end of
**                the list.
** notes:         none.
************************************************************/
void printGrades(gradeType* gList);

/************************************************************
** function:      printGrade
** description:   prints the grade id, name, and value.
** notes:         none.
************************************************************/
void printGrade(gradeType *grade);

/************************************************************
** function:      getGrade
** description:   returns the grade object for the passed id.
** notes:         returns NULL the id is not found.
************************************************************/
gradeType* getGrade(int id, gradeType* gList);

/************************************************************
** function:      getFirstGrade
** description:   returns the head of the grade list.
** notes:         none.
************************************************************/
gradeType* getFirstGrade(gradeType* gList);
gradeType  getFirstGradeNP();

/************************************************************
** function:      getPrevGrade
** description:   returns the previous grade in the list.
** notes:         returns NULL if 'g' is the first grade in
**                the list.
************************************************************/
gradeType* getNextGrade(gradeType* gList);

/************************************************************
** function:      getNextGrade
** description:   returns the next grade in the list.
** notes:         returns NULL if 'g' is the last grade in
**                the list.
************************************************************/
gradeType* getPrevGrade(gradeType* gList);

/************************************************************
** function:      totalGradess
** description:   returns the total number of allocated grades.
** notes:         none.
************************************************************/
int totalGradess(gradeType* gList);

/************************************************************
** function:      checkGradeID
** description:   returns true if the selection value is 
**	notes:			found in the grade linked list given.
** 		         none.
************************************************************/
bool checkGradeID(gradeType* gList, int selection);
#endif
